package com.auxgroup.smarthome;

/**
 * Created by kevinchen on 2017/9/5.
 * 峰谷节电、智能用电控制协议表 （只限于家用空调）
 * 协议详见A17表
 */
public enum ElectricalCurveControlEnum {

    PERCENTAGE_OF_INTELLIGENT_ELECTRICITY("percentage_of_intelligent_electricity",8,"智能用电功率百分比",1,200),
    OBLIGATE_10("obligate_10",2,"预留10",0,3),
    OBLIGATE_9("obligate_9",1,"预留9",0,1),
    OBLIGATE_8("obligate_8",1,"预留8",0,1),
    OBLIGATE_7("obligate_7",1,"预留7",0,1),
    INTELLIGENT_ELETRICITY("intelligent_electricity",1,"智能用电打开",0,1),
    PEAK_TO_VALLEY_POWER("peak_to_valley_power",2,"峰谷节点",0,3);



    /**
     * 数据点字段名称
     */
    private String name;

    /**
     * 在协议中二进制中所占bit位数
     */
    private int bitCount;
    /**
     * 中文描述
     */
    private String displayName;
    /**
     * 最小值
     */
    private int min;
    /**
     * 最大值
     */
    private int max;

    ElectricalCurveControlEnum(String name, int bitCount, String displayName, int min, int max) {
        this.name = name;
        this.bitCount = bitCount;
        this.displayName = displayName;
        this.min = min;
        this.max = max;
    }


    public String getName() {
        return name;
    }

    public int getBitCount() {
        return bitCount;
    }

    public int getMin() {
        return min;
    }

    public int getMax() {
        return max;
    }


    public static ElectricalCurveControlEnum getElectricalCurveControlEnum(String datapointAttr){
        if (ElectricalCurveControlEnum.PERCENTAGE_OF_INTELLIGENT_ELECTRICITY.getName()
                .equals(datapointAttr)){
            return ElectricalCurveControlEnum.PERCENTAGE_OF_INTELLIGENT_ELECTRICITY;
        }else if (ElectricalCurveControlEnum.PEAK_TO_VALLEY_POWER.getName().equals(datapointAttr)){
            return ElectricalCurveControlEnum.PEAK_TO_VALLEY_POWER;
        }else if (ElectricalCurveControlEnum.INTELLIGENT_ELETRICITY.getName().equals(datapointAttr)){
            return ElectricalCurveControlEnum.INTELLIGENT_ELETRICITY;
        }else if (ElectricalCurveControlEnum.OBLIGATE_10.getName().equals(datapointAttr)){
            return ElectricalCurveControlEnum.OBLIGATE_10;
        }else if (ElectricalCurveControlEnum.OBLIGATE_9.getName().equals(datapointAttr)){
            return ElectricalCurveControlEnum.OBLIGATE_9;
        }else if (ElectricalCurveControlEnum.OBLIGATE_8.getName().equals(datapointAttr)){
            return ElectricalCurveControlEnum.OBLIGATE_8;
        }else if (ElectricalCurveControlEnum.OBLIGATE_7.getName().equals(datapointAttr)){
            return ElectricalCurveControlEnum.OBLIGATE_7;
        }else {
            throw new IllegalArgumentException("传入的普通控制的控制参数不合法！");
        }
    }



}
